﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace CYP.IISMonitor.WebTest
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["d"] != null)
            {
                bool bo = Execute();
                if (bo)
                {
                    Response.AddHeader("result", "true");
                }
            }
        }

        private bool Execute()
        {
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = "server=.;database=test;uid=sa;pwd=pass@word1;";
                SqlCommand cmd = new SqlCommand("select count(1) from t1;");
                cmd.Connection = conn;
                conn.Open();
                object obj = cmd.ExecuteScalar();
                conn.Close();
                if (obj != null)
                {
                    return true;
                }
            }
            return false;
        }
    }
}